var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) {
	conn.createChannel(function(err, ch) {
		var ex = 'topic_logs'; // exchange
		var msg = 'hello world ';

		ch.assertExchange(ex, 'topic', {
			durable: false
		});

		var keys = [
			'quick.orange.rabbit',
			'lazy.orange.elephant',
			'lazy.brown.fox',
			'lazy.pink.rabbit',
			'quick.orange.male.rabbit'
		];
		
		// send to exchange
		setInterval(function() {
			rdmIndex = Math.floor(Math.random() * keys.length);
			ch.publish(ex, keys[rdmIndex], new Buffer(msg + keys[rdmIndex]));
			console.log(" [x] %s, %s", keys[rdmIndex], msg);
		}, 2000);
	});
});

// node p.js